import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('zuser', () => {
  const token = ref('')
  const setToken = (newToken) => {
    console.log("store设置token")
    token.value = newToken
  }
  const removeToken = () => {
    console.log("store移除token")
    token.value = ''
  }
  const user = ref({})
  
  const setUser = (obj) => {
    console.log("store设置user")
    console.log(obj)
    user.value = obj
  }
  return { 
    token,
    user,
    setToken,
    removeToken,
    setUser

  }
}
,{
  persist: true,
}
)
